<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">

<ui:composition template="/WEB-INF/template/template.xhtml">
	<ui:define name="content">
		<h:form>
			<br />

			<br />
			<div class="middle">
				<h2>
					<h:outputText value="#{msg.AD_decideReplacer_header}" />
				</h2>
			</div>
			<br />
			<div class="middle">
				<h:outputText style="color:grey;"
					value="#{msg.AD_decideReplacer_msg1}"
					rendered="#{empty decideReplacerBean.toReplaceUserList}">
				</h:outputText>
			</div>
			<br />
			<h:panelGrid class="panelGrid"
				rendered="#{not empty decideReplacerBean.toReplaceUserList}">
				<f:facet name="header">
					<h:outputText value="#{msg.AD_decideReplacer_msg2}" />
				</f:facet>
				<h:selectOneRadio id="radioUser" value="#{decideReplacerBean.repId}"
					valueChangeListener="#{decideReplacerBean.updateReplacedId}"
					onchange="submit()" layout="pageDirection">
					<f:selectItems value="#{decideReplacerBean.toReplaceUserList}"
						var="toReplaceUser" itemLabel="#{toReplaceUser.name}"
						itemValue="#{toReplaceUser.id}" />
				</h:selectOneRadio>
			</h:panelGrid>
			<br />

			<br />
			<h:panelGrid class="panelGrid middle"
				rendered="#{decideReplacerBean.userDTO!=null and decideReplacerBean.avemManageriActivi}">

				<div class="middle">
					<h:outputText value=" Replace with &nbsp;"
						rendered="#{not empty decideReplacerBean.toReplaceUserList}">
					</h:outputText>
					<h:selectOneMenu id="select" value="#{decideReplacerBean.omId}"
						valueChangeListener="#{decideReplacerBean.updateReplacerId}"
						onchange="submit()"
						rendered="#{not empty decideReplacerBean.toReplaceUserList}">
						<f:selectItems value="#{decideReplacerBean.officeManagersList}"
							var="dataItem2" itemLabel="#{dataItem2.name}"
							itemValue="#{dataItem2.id}">
						</f:selectItems>
					</h:selectOneMenu>
					<h:commandButton class="button middle" value="Add Replacer"
						render="tabelRU tabelUR"
						actionListener="#{decideReplacerBean.performReplace}"
						onclick="#{msg.AD_decideReplacer_msg4}"
						rendered="#{not empty decideReplacerBean.toReplaceUserList}">
						<f:attribute name="addReplacer" value="#{dataItem}" />
						<f:attribute name="inactiveOfficeManager"
							value="#{decideReplacerBean.toReplaceUserList[0]}" />
					</h:commandButton>
				</div>
			</h:panelGrid>
			<br />
			<br />
			<h:dataTable id="tabelRU" class="table" border="1"
				value="#{decideReplacerBean.replacedUserList}"
				var="replacedUserDataItem"
				rendered="#{not empty decideReplacerBean.replacedUserList}">
				<h:column>
					<f:facet name="header">
						<h:outputText value="#{msg.AD_decideReplacer_msg5}"></h:outputText>
					</f:facet>
					<h:outputText value="#{replacedUserDataItem.name}"></h:outputText>
				</h:column>
				<h:column>
					<f:facet name="header">
                                       <h:outputText value="#{msg.AD_decideReplacer_msg6}"></h:outputText>
                                       </f:facet>
					<h:outputText
						value="#{decideReplacerBean.getOM(replacedUserDataItem.id).name}"></h:outputText>

				</h:column>
				<h:column>
					<f:facet name="header">
                                       <h:outputText value="#{msg.AD_decideReplacer_msg7}"></h:outputText>
                                       </f:facet>
					<h:commandButton class="trashBtn" value="REMOVE"
						render="tabelUR tabelRU"
						actionListener="#{decideReplacerBean.replacementDone}">
						<f:attribute name="replacedUser" value="#{replacedUserDataItem}" />
					</h:commandButton>
				</h:column>


			</h:dataTable>
		</h:form>
	</ui:define>
</ui:composition>
</html>
